<template>
    <div class="index">
        <el-container>
        <el-header>Header</el-header>
        <el-container>
            <!-- 侧边栏 -->
            <el-aside width="200px">
                <el-menu
                default-active="2"
                class="el-menu-vertical-demo"
                background-color="#545c64"
                text-color="#fff"
                router
                active-text-color="#ffd04b">
                <el-submenu :index="index+''"  v-for="item,index in menusList" :key="index">
                    <template slot="title">
                        <i :class="iconList[item.id]"></i>
                        <span>{{item.authName}}</span>
                    </template>
                    <el-menu-item :index="'/index/'+ele.path" v-for="(ele,i) in item.children" :key="i">{{ele.authName}}</el-menu-item>
                </el-submenu>
                </el-menu>
            </el-aside>
            <!-- 坑 -->
            <el-main>
                <!-- 面包屑 -->
                <router-view></router-view>
            </el-main>
        </el-container>
        </el-container>
    </div>
</template>
<script>
import {getMenusApi} from '@/utils/api.js'
export default {
    data() {
        return {
            menusList:[],//存放侧边栏数据
            iconList:{
                125:'el-icon-user-solid',
                103:'el-icon-star-on',
                101:'el-icon-s-goods',
                102:'el-icon-s-order',
                145:'el-icon-s-data'
            }
        }
    },
    created() {
        this.getMenus()
    },
    methods: {
        async getMenus(){
          this.menusList = await getMenusApi()
          console.log(this.menusList);
        }
    },
}
</script>
<style lang="scss" scoped>
.el-header, .el-footer {
    background-color: #333;
    color: #fff;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: #333;
    color: #fff;
    text-align: center;
    line-height: 200px;
  }
  

</style>
